
var namecardlistName = '';
var vm = new Vue({
    el:"#nameCardList",
    data:{
        nameCardList:'',
    },
    // 方法存放区
    methods: {

        getAllNameCardListInfo() {
            axios({
                method: 'POST',
                url: 'http://localhost:8099/nameCardList/getNameCardList',
            }).then(function (result) {
                vm.nameCardList = result.data;
                // console.log(vm.nameCardList)
            }).catch(function (reason) {
                console.log(reason);
            })
        },
        //跳转查看详情页面
        goView(namecardlistName) {
            axios({
                method: 'POST',
                url: 'http://localhost:8099/nameCardList/setNamecardlistName',
                data:{
                    "namecardlistName":namecardlistName
                }
            }).then(function (result) {
                location.href="nameCardView.html"
                console.log(namecardlistName)
            }).catch(function (reason) {
                console.log(reason);
            })
        },
        //跳转更名页面
        updateName(namecardlistId) {
            axios({
                method: 'POST',
                url: 'http://localhost:8099/nameCardList/getNameCardList'
            }).then(function (result) {
                location.href="nameCardUpdate.html?id="+namecardlistId
                // console.log(vm.nameCardList)
            }).catch(function (reason) {
                console.log(reason);
            })
        },

        // 删除
        deleteNameCard(namecardlistId) {
            namecardlistName = namecardlistId;
            $(".tip").fadeIn(200);
        },

        // 删除确认
        delectCheck() {
            console.log(namecardlistName)
            axios.post('http://localhost:8099/nameCardList/delete/' +namecardlistName)
                .then(function (response) {
                    // alert(response.data)
                    vm.getAllNameCardListInfo();
                })
                .catch(function (error) {
                    alert(response.data)
                });
        },

    },

    //页面加载完自动执行
    mounted(){
        this.getAllNameCardListInfo();
    }

})